package com.my.kq.controller;

import com.my.kq.entity.Employee;
import com.my.kq.entity.Leave;
import com.my.kq.service.EmployeeService;
import com.my.kq.service.LesveService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

@WebServlet("/LeaveList")
//查询请假
public class LeaveList extends HttpServlet {
    private EmployeeService EmployeeService=new EmployeeService();
    private LesveService lesveService=new LesveService();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        try {
            req.setCharacterEncoding("utf-8");
            resp.setCharacterEncoding("utf-8");
            resp.setContentType("text/html;charset=utf-8");
            HttpSession session = req.getSession();
            Employee cook =(Employee) session.getAttribute("cook");
            Integer id = cook.getId();
            Employee yee= EmployeeService.Empcx(id);
         //员工编号
            Integer number = yee.getEmployee_number();
           List<Leave> list =lesveService.leaveList(number);
           req.setAttribute("list",list);
           req.setAttribute("employee",yee);
           req.getRequestDispatcher("jsp/admin/leave_list.jsp").forward(req,resp);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
